package truef.favoriteshop.web.spring.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.google.gson.Gson;

import edu.zut.cs.software.base.web.spring.controller.GenericController;
import truef.favoriteshop.domain.Favorite;
import truef.reorder.domain.ReturnOrder;
import truef.service.favoriteshop.service.FavoriteManager;

@Controller
//拦截含有favorite的url并处理
@RequestMapping("/favorite") // 7.
public class FavoriteController extends GenericController<Favorite, Long, FavoriteManager> {
	FavoriteManager favoriteManager;

	/*
	 * 部署成功后，在浏览器中输入url http://localhost:8080/universalStore-web/${1.}/${2.value值}
	 * 例子:http://localhost:8080/universalStore-web/favorite/index.html
	 */
	@CrossOrigin(origins = "*")
	@ResponseBody
	@RequestMapping(value = "/findall.json",produces = "text/plain;charset=utf-8")
	public String findall() {
		List<Favorite> CommentList = favoriteManager.findAll();
		Gson gson = new Gson();
		String s = gson.toJson(CommentList);
		return s;
	}
	@RequestMapping(value="/getJosn.do", produces="text/html;charset=UTF-8")  
	@ResponseBody  
	public String getTabJson(){  
	    String json = "{无主题:https://wuzhuti.cn}";  
	    return json;  
	}  

	@Autowired
	public void setUserManager(FavoriteManager favoriteManager) {
		this.favoriteManager = favoriteManager;
		this.manager = this.favoriteManager;
	}
	

}